﻿<sdk:Page x:Class="SampleBrowser.Views.SampleMetadata" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
           xmlns:doc="http://schemas.firstfloorsoftware.com/documenttoolkit"
           xmlns:dte="http://schemas.firstfloorsoftware.com/documenttoolkit/extensions"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Metadata">
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width=".4*" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <TextBlock x:Name="HeaderText" Grid.ColumnSpan="2" Style="{StaticResource HeaderTextStyle}" Text="Metadata"/>

        <doc:DocumentDataSource x:Name="DataSource" PropertyChanged="DataSource_PropertyChanged" LoadError="DataSource_LoadError">
            <!-- ensure all metadata is actually loaded -->
            <doc:DocumentDataSource.LoadDocumentSettings>
                <doc:LoadXpsDocumentSettings IncludeDocumentStructures="True" IncludeProperties="True" />
            </doc:DocumentDataSource.LoadDocumentSettings>
            <doc:DocumentDataSource.LoadPageSettings>
                <doc:LoadFixedPageSettings IncludeStoryFragments="True" />
            </doc:DocumentDataSource.LoadPageSettings>
        </doc:DocumentDataSource>

        <sdk:TreeView x:Name="TreeView" Grid.Row="1" SelectedItemChanged="TreeView_SelectedItemChanged">
            <sdk:TreeView.ItemTemplate>
                <sdk:HierarchicalDataTemplate ItemsSource="{Binding Children}">
                    <StackPanel Orientation="Horizontal">
                        <Image Margin="0,0,4,0" Width="16" Height="16" Source="{Binding Icon}" />
                        <TextBlock Text="{Binding Text}" VerticalAlignment="Center" />
                    </StackPanel>
                </sdk:HierarchicalDataTemplate>
            </sdk:TreeView.ItemTemplate>
        </sdk:TreeView>
        
        <doc:DocumentViewer x:Name="Viewer"
                            Grid.Column="1" Grid.Row="1"
                            DocumentDataSource="{Binding ElementName=DataSource}"
                            ViewMode="{Binding SelectedViewMode, ElementName=ViewModePicker}">
        </doc:DocumentViewer>

        <StackPanel Grid.ColumnSpan="2" Grid.Row="2" Orientation="Horizontal" Margin="0,8,0,0" HorizontalAlignment="Center">
            <doc:HistoryNavigator History="{Binding History, ElementName=Viewer}" />
            <doc:PageNavigator x:Name="Navigator"
                               PageCount="{Binding PageCount, ElementName=Viewer}"
                               PageIndex="{Binding PageIndex, ElementName=Viewer, Mode=TwoWay}"
                               Margin="4,0,0,0" />
            <doc:ViewModePicker x:Name="ViewModePicker" Margin="4,0,0,0" />

            <Button Margin="4,0,0,0" Padding="7">
                <Button.Command>
                    <dte:OpenPdfOrXpsFromDiskCommand DocumentDataSource="{Binding ElementName=DataSource}" />
                </Button.Command>
                <Button.Content>
                    <Image Source="/SampleBrowser;component/Assets/Icons/open.png" />
                </Button.Content>
            </Button>

        </StackPanel>
    </Grid>
</sdk:Page>
